package com.gensdai.leliang.dialog;

import android.app.ActionBar;
import android.app.Dialog;
import android.content.Context;
import android.view.Gravity;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.EditText;
import android.widget.TextView;

import com.gensdai.leliang.R;

/**
 * Created by Administrator on 2017/7/26.
 */

public class UserSexDialog {
    Context mContext;
    Dialog dialog;
    EditText name = null;
    public final static int WULIU = 4;

    public UserSexDialog(Context mContext, int select) {
        super();
        this.mContext = mContext;
        if (select == 1) {
            initSexdialog();
        } else if (select == 2) {
            initdialog();
        } else if (select == 3) {
            initIMGdialog();
        }else if(select == WULIU){
            initWULIUdialog();
        }

    }

    // 性别选择
    public void initSexdialog() {


        TextView man;
        TextView weman;
        TextView b;

        dialog = new Dialog(mContext, R.style.dialog_head);
        dialog.setContentView(R.layout.user_sex);
        Window dialogWindow = dialog.getWindow();
        dialogWindow.setLayout(ActionBar.LayoutParams.WRAP_CONTENT, ActionBar.LayoutParams.WRAP_CONTENT);
        WindowManager.LayoutParams lp = dialogWindow.getAttributes();
        dialogWindow.setGravity(Gravity.BOTTOM);
//    	dialogWindow.setWindowAnimations(R.anim.head_start_dialog);
//    	dialog.setCanceledOnTouchOutside(true);
        dialog.setCanceledOnTouchOutside(false);

        man = (TextView) dialog.findViewById(R.id.man);
        weman = (TextView) dialog.findViewById(R.id.weman);
        b = (TextView) dialog.findViewById(R.id.b);

        man.setOnClickListener((View.OnClickListener) mContext);
        weman.setOnClickListener((View.OnClickListener) mContext);
        b.setOnClickListener((View.OnClickListener) mContext);


    }

    // 昵称
    public void initdialog() {


        TextView y;
        TextView b;

        dialog = new Dialog(mContext, R.style.dialog_head);
        dialog.setContentView(R.layout.user_set_name);
        Window dialogWindow = dialog.getWindow();
        dialogWindow.setLayout(ActionBar.LayoutParams.WRAP_CONTENT, ActionBar.LayoutParams.WRAP_CONTENT);
        WindowManager.LayoutParams lp = dialogWindow.getAttributes();
        dialogWindow.setGravity(Gravity.CENTER);
//    	dialogWindow.setWindowAnimations(R.anim.head_start_dialog);
//    	dialog.setCanceledOnTouchOutside(true);
        dialog.setCanceledOnTouchOutside(false);

        name = (EditText) dialog.findViewById(R.id.name);
        y = (TextView) dialog.findViewById(R.id.y);
        b = (TextView) dialog.findViewById(R.id.b);

        y.setOnClickListener((View.OnClickListener) mContext);
        b.setOnClickListener((View.OnClickListener) mContext);


    }

    // 头像
    public void initIMGdialog() {


        TextView photograph;
        TextView photo_album;
        TextView b;

        dialog = new Dialog(mContext, R.style.dialog_head);
        dialog.setContentView(R.layout.user_img);
        Window dialogWindow = dialog.getWindow();
        dialogWindow.setLayout(ActionBar.LayoutParams.WRAP_CONTENT, ActionBar.LayoutParams.WRAP_CONTENT);
        WindowManager.LayoutParams lp = dialogWindow.getAttributes();
        dialogWindow.setGravity(Gravity.BOTTOM);
//    	dialogWindow.setWindowAnimations(R.anim.head_start_dialog);
//    	dialog.setCanceledOnTouchOutside(true);
        dialog.setCanceledOnTouchOutside(false);

        photograph = (TextView) dialog.findViewById(R.id.photograph);
        photo_album = (TextView) dialog.findViewById(R.id.photo_album);
        b = (TextView) dialog.findViewById(R.id.b);

        photograph.setOnClickListener((View.OnClickListener) mContext);
        photo_album.setOnClickListener((View.OnClickListener) mContext);
        b.setOnClickListener((View.OnClickListener) mContext);


    }

    // 确认物流
    public void initWULIUdialog() {


        TextView dc;
        TextView qd;

        dialog = new Dialog(mContext, R.style.dialog_head);
        dialog.setContentView(R.layout.wuliu_dialog);
        Window dialogWindow = dialog.getWindow();
        dialogWindow.setLayout(ActionBar.LayoutParams.WRAP_CONTENT, ActionBar.LayoutParams.WRAP_CONTENT);
        WindowManager.LayoutParams lp = dialogWindow.getAttributes();
        dialogWindow.setGravity(Gravity.CENTER);
//    	dialogWindow.setWindowAnimations(R.anim.head_start_dialog);
//    	dialog.setCanceledOnTouchOutside(true);
        dialog.setCanceledOnTouchOutside(false);

        qd = (TextView) dialog.findViewById(R.id.j);
        dc = (TextView) dialog.findViewById(R.id.q);

        qd.setOnClickListener((View.OnClickListener) mContext);
        dc.setOnClickListener((View.OnClickListener) mContext);
    }

    public void show() {
        dialog.show();
    }

    public String getName() {
        if (name != null) {
            return name.getText().toString().trim();
        }
        return "";
    }

    public void dismiss() {
        if (dialog != null && dialog.isShowing())
            dialog.dismiss();
    }

    public boolean isShowing() {
        return dialog.isShowing();
    }
}
